package com.csu.bailan.util;

import com.csu.bailan.common.CommonResponse;
import com.csu.bailan.common.ResponseEnum;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.ConstraintViolationException;

@ControllerAdvice
public class GlobalExceptionHandle {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public CommonResponse<String> handleException(Exception e){
        return CommonResponse.createForError(ResponseEnum.ARGUMENTILLEGAL.getCode(),e.getMessage());
    }
}
